Java syntax
part 4/46 · 86.7 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• byte
• case
• catch
• char
• class
• continue
• default
• do
• double
• else
• enum
• extends
• final
• finally
• float
• for
• if
• implements
• import
• instanceof
• int
• interface
• long
• native
• new
• package
• private
• protected
• public
• return
• short
• static
• super
• switch
• synchronized
• this
• throw
• throws
• transient
• try
• void
• volatile
• while
Reserved identifiers
The following words are contextual keywords and are only restricted in certain contexts.
• exports
• module
• non-sealed
• open
• opens
• permits
• provides
• record
• requires
• sealed
• to
• transitive
• var
• when
• with
• yield
Reserved words for literal values
The following words refer to literal values used by the language.
• true
• false
• null
Unused
The following words are reserved as keywords, but currently have no use or purpose.
• const
• goto
• strictfp
Literals
| Integers | Integers |
|---|---|
| binary (introduced in Java SE 7) | 0b11110101 ( 0b followed by a binary number) |
| octal | 0365 ( 0 followed by an octal number) |
| hexadecimal | 0xF5 ( 0x followed by a hexadecimal number) |
| decimal | 245 (decimal number) |
| Floating-point values | Floating-point values |
| float | 23.5F , .5f , 1.72E3F (decimal fraction with an optional exponent indicator, followed by F ) |
| float | 0x.5FP0F , 0x.5P-6f ( 0x followed by a hexadecimal fraction with a mandatory exponent indicator and a suffix F ) |
| double | 23.5D , .5 , 5. , 1.72E3D (decimal fraction with an optional exponent indicator, followed by optional D ) |
| double | 0x.5FP0 , 0x.5P-6D ( 0x followed by a hexadecimal fraction with a mandatory exponent indicator and an optional suffix D ) |
| Character literals | Character literals |
| char | 'a' , 'Z' , '\u0231' (character or a character escape, enclosed in single quotes) |
| Boolean literals | Boolean literals |
| boolean | true , false |
| null literal | null literal |
| null reference | null |
| String literals | String literals |
| String | "Hello, World" (sequence of characters and character escapes enclosed in double quotes) |
| Characters escapes in strings | Characters escapes in strings |
| Unicode character | \u3876 ( \u followed by the hexadecimal unicode code point up to U+FFFF) |
| Octal escape | \352 (octal number not exceeding 377, preceded by backslash) |
| Line feed | \n |
| Carriage return | \r |
| Form feed | \f |
| Backslash | \\ |
| Single quote | \' |
| Double quote | \" |
| Tab | \t |
| Backspace | \b |
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────